/*
 */

package com.railway.system.service.impl;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.text.SimpleDateFormat;
import java.util.*;

import org.apache.commons.lang.StringUtils;

import com.railway.common.base.*;
import com.railway.common.constants.SysConstant;
import com.railway.common.util.*;

import cn.org.rapid_framework.util.*;
import cn.org.rapid_framework.web.util.*;
import cn.org.rapid_framework.page.*;
import cn.org.rapid_framework.page.impl.*;

import com.railway.system.dao.*;
import com.railway.system.model.*;
import com.railway.system.service.*;
import com.railway.system.vo.query.*;

/**
 * @author  jiangcheng
 * @version 1.0
 * @since 1.0
 */


@Service("sysUserManager")
@Transactional
public class SysUserManagerImpl extends BaseManager<SysUser,java.lang.String> implements ISysUserManager{

	private ISysUserDao sysUserDao;
	/**增加setXXXX()方法,spring就可以通过autowire自动设置对象属性,请注意大小写*/
	public void setSysUserDao(ISysUserDao dao) {
		this.sysUserDao = dao;
	}
	public EntityDao getEntityDao() {
		return (EntityDao)this.sysUserDao;
	}
	
	@Transactional(readOnly=true)
	public Page findPage(SysUserQuery query) {
		System.out.print(sysUserDao);
		return sysUserDao.findPage(query);
	}
	@Transactional(readOnly=true)
	public SysUser getById(java.lang.String id){
		System.out.print(sysUserDao.getById(id));
		return sysUserDao.getById( id);
	}
	@Transactional
	public void removeById(java.lang.String id){
		sysUserDao.deleteById(id);
	}
	
	/** 插入数据 */
	@Transactional
	public String saveUser(SysUser entity){
		try{
		  //如果部门ID为空,明确地插入'EMPTY'作为标示 
			if(entity.getDeptId() == null){
				entity.setDeptId(SysConstant.SYS_EMPTY_VALUE);
			}
		  return  sysUserDao.saveUser(entity);
		}catch(Exception e){
		 
		  	e.printStackTrace();
		}
	    return ""; 
	}
	
	/** 更新数据 */
	@Transactional
	public void update(SysUser entity){
		sysUserDao.update(entity);
	}
	@Transactional(readOnly=true)
	public boolean isUnique(SysUser entity, String uniquePropertyNames){
		return super.isUnique( entity, uniquePropertyNames);
	}
	@Transactional(readOnly=true)
	public List<SysUser> findAll(){
		return super.findAll();
	}
	@Transactional
	public void saveOrUpdate(SysUser entity) {
		super.saveOrUpdate(entity);
	}
	/**
	 * 根据部门id获得用户列表
	 */
	@Transactional(readOnly=true)
	public List getUsersByDeptId(String deptid) {
		 return sysUserDao.getUsersByDeptId(deptid);
	}
	@Transactional(readOnly=true)
	public List getUsers(SysUserQuery query) { 
		return sysUserDao.getUsers(query);
	}

}
